package com.star.domain;


import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 页面区域配置
 *
 * @author 孙星阳
 * @date 2017/9/27 下午3:35
 */
@Table(name = "conf_page_region")
@Entity
@Getter
@Setter
@ToString
@AllArgsConstructor
public class PageParseRegion extends AbstractEntity {
    /**
     *
     */
    public PageParseRegion() {
        fieldParseRules = new HashSet<>();
        urlParseRules = new HashSet<>();
    }

    private static final long serialVersionUID = 1L;

    @Column(name = "pageId", nullable = false, columnDefinition = "varchar(38)")
    private String pageId;

    @Column(name = "name", nullable = false)
    private String name;

    @Column(name = "dataType", nullable = false, columnDefinition = "varchar(38) default 'MAP'")
    private String dataType;

    /**
     * 区域选择表达式
     */
    @Column(name = "selectExpression", columnDefinition = "varchar(100)")
    private String selectExpression;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "regionId", insertable = false, updatable = false)
    private Set<FieldParseRule> fieldParseRules;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "regionId", insertable = false, updatable = false)
    @OrderBy(value = "id ASC")
    private Set<UrlParseRule> urlParseRules;
}